

var spinner_div = null;
setTimeout('show_spinner()', 100);

// sends page URL to TaxonFinder service to be marked up
include_js(markit_api_prefix + '?callback=callback_replace_page_html&url=' + location.href);

// callback which gets results of TaxonFinder markup service
function callback_replace_page_html(obj)
{
    hide_spinner();
    document.body.innerHTML = obj.html;
    if(typeof namelink_replace_tags == 'function') {
        setTimeout('namelink_replace_tags()', 500);
    }
}

// dynamically include external javascript
function include_js(location)
{
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = location;
    
    var head = document.getElementsByTagName('head')[0];
    head.appendChild(script);
}



function show_spinner()
{
    spinner_div = document.createElement('div');
    spinner_div.setAttribute('id', 'namelink_spinner_div');
    spinner_div.className = 'namelink_spinner_show';
    
    var body = document.getElementsByTagName('body')[0];
    if(body) { 
        body.appendChild(spinner_div);
    }
}

function hide_spinner()
{
    var spinner_div = document.getElementById('namelink_spinner_div');
    if(spinner_div && spinner_div.style)
    { 
        spinner_div.className = 'namelink_spinner_hide';
    }
}
